// County to districts: https://www.legis.iowa.gov/legislators/redistricting?year=2001
//Jefferson county precincts at: http://www.johnson-county.com/dept_auditor_elections.aspx?id=14358
	// and http://www.johnson-county.com/auditor/returns/0611leg.htm
replace sldl=29 if precinct=="Big Grove" & county=="Johnson"
replace sldl=29 if precinct=="Cedar" & county=="Johnson"
replace sldl=29 if precinct=="City Of Solon" & county=="Johnson"
replace sldl=29 if precinct=="Clear Creek" & county=="Johnson"
replace sldl=29 if precinct=="Graham" & county=="Johnson"
replace sldl=29 if precinct=="Hardin" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 10" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 12" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 14" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 15" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 17" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 18" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 22" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 23" & county=="Johnson"
replace sldl=78 if precinct=="Iowa City 24" & county=="Johnson"
replace sldl=77 if precinct=="Iowa City 6" & county=="Johnson"
replace sldl=29 if precinct=="Jefferson East" & county=="Johnson"
replace sldl=29 if precinct=="Jefferson West" & county=="Johnson"
replace sldl=29 if precinct=="Madison" & county=="Johnson"
replace sldl=29 if precinct=="Monroe" & county=="Johnson"
replace sldl=29 if precinct=="Newport" & county=="Johnson"
replace sldl=29 if precinct=="Oxford" & county=="Johnson"

replace sldl=9 if precinct=="Johnson" & county=="Webster" & sldl==4 & year==2004
replace sldl=44 if county=="Marshall" & sldl==64 & year==2004

replace sldl=58 if county=="Adair"
replace sldl=96 if county=="Adams"
replace sldl=16 if county=="Allamakee"
replace sldl=94 if county=="Appanoose"
replace sldl=58 if county=="Audubon"
replace sldl=39 if county=="Benton"
replace sldl=23 if county=="Buchanan"
replace sldl=52 if county=="Buena Vista"
replace sldl=17 if county=="Butler"
replace sldl=50 if county=="Calhoun"
replace sldl=51 if county=="Carroll"
replace sldl=79 if county=="Cedar"
replace sldl=53 if county=="Cherokee"
replace sldl=15 if county=="Chickasaw"
replace sldl=95 if county=="Clarke"
replace sldl=24 if county=="Clayton"
replace sldl=94 if county=="Davis"
replace sldl=95 if county=="Decatur"
replace sldl=6 if county=="Dickinson"
replace sldl=7 if county=="Emmet"
replace sldl=14 if county=="Floyd"
replace sldl=97 if county=="Fremont"
replace sldl=50 if county=="Greene"
replace sldl=40 if county=="Grundy"
replace sldl=58 if county=="Guthrie"
replace sldl=44 if county=="Hardin"
replace sldl=56 if county=="Harrison"
replace sldl=91 if county=="Henry"
replace sldl=8 if county=="Humboldt"
replace sldl=55 if county=="Ida"
replace sldl=25 if county=="Jackson"
replace sldl=31 if county=="Jones"
replace sldl=76 if county=="Keokuk"
replace sldl=87 if county=="Louisa"
replace sldl=72 if county=="Lucas"
replace sldl=4 if county=="Lyon"
replace sldl=73 if county=="Madison"
replace sldl=14 if county=="Mitchell"
replace sldl=72 if county=="Monroe"
replace sldl=96 if county=="Montgomery"
replace sldl=5 if county=="O'Brien" | county=="Obrien"
replace sldl=5 if county=="Osceola"
replace sldl=97 if county=="Page"
replace sldl=7 if county=="Palo Alto"
replace sldl=8 if county=="Pocahontas"
replace sldl=96 if county=="Ringgold"
replace sldl=57 if county=="Shelby"
replace sldl=96 if county=="Taylor"
replace sldl=90 if county=="Van Buren"
replace sldl=89 if county=="Washington"
replace sldl=94 if county=="Wayne"
replace sldl=11 if county=="Winnebago"
replace sldl=11 if county=="Worth"
replace sldl=9 if county=="Wright"
replace sldl=12 if precinct=="Falls Plymouth Lime Creek Mason N Twps Pct 265" //typo
replace sldl=15 if precinct=="Jamestown Twp., Saratoga Twp., & Howard C 146" //typo
replace sldl=75 if county=="Mahaska" & sldl==38 //typo
replace sldl=72 if county=="Mahaska" & sldl==36 //typo
replace sldl=43 if county=="Marshall" & sldl==63  //typo
replace sldl=44 if county=="Marshall" & sldl==65 //typo
replace sldl=56 if county=="Pottawattamie" & sldl==28 //typo
replace sldl=8 if county=="Pottawattamie" & sldl==4 //typo

replace sldu=29 if county=="Adair" & sldl==58
replace sldu=48 if county=="Adams" & sldl==96
replace sldu=8 if county=="Allamakee" & sldl==16
replace sldu=47 if county=="Appanoose" & sldl==94
replace sldu=29 if county=="Audubon" & sldl==58
replace sldu=20 if county=="Benton" & sldl==39
replace sldu=9 if county=="Black Hawk" & sldl==18
replace sldu=10 if county=="Black Hawk" & sldl==19
replace sldu=10 if county=="Black Hawk" & sldl==20
replace sldu=11 if county=="Black Hawk" & sldl==21
replace sldu=11 if county=="Black Hawk" & sldl==22
replace sldu=12 if county=="Black Hawk" & sldl==23
replace sldu=23 if county=="Boone" & sldl==46
replace sldu=24 if county=="Boone" & sldl==47
replace sldu=24 if county=="Boone" & sldl==48
replace sldu=9 if county=="Bremer" & sldl==17
replace sldu=9 if county=="Bremer" & sldl==18
replace sldu=12 if county=="Buchanan" & sldl==23
replace sldu=26 if county=="Buena Vista" & sldl==52
replace sldu=9 if county=="Butler" & sldl==17
replace sldu=25 if county=="Calhoun" & sldl==50
replace sldu=26 if county=="Carroll" & sldl==51
replace sldu=29 if county=="Cass" & sldl==57
replace sldu=29 if county=="Cass" & sldl==58
replace sldu=40 if county=="Cedar" & sldl==79
replace sldu=6 if county=="Cerro Gordo" & sldl==12
replace sldu=7 if county=="Cerro Gordo" & sldl==13
replace sldu=7 if county=="Cerro Gordo" & sldl==14
replace sldu=27 if county=="Cherokee" & sldl==53
replace sldu=8 if county=="Chickasaw" & sldl==15
replace sldu=48 if county=="Clarke" & sldl==95
replace sldu=3 if county=="Clay" & sldl==5
replace sldu=3 if county=="Clay" & sldl==6
replace sldu=12 if county=="Clayton" & sldl==24
replace sldu=13 if county=="Clinton" & sldl==25
replace sldu=13 if county=="Clinton" & sldl==26
replace sldu=42 if county=="Clinton" & sldl==83
replace sldu=26 if county=="Crawford" & sldl==51
replace sldu=28 if county=="Crawford" & sldl==55
replace sldu=24 if county=="Dallas" & sldl==47
replace sldu=24 if county=="Dallas" & sldl==48
replace sldu=37 if county=="Dallas" & sldl==73
replace sldu=47 if county=="Davis" & sldl==94
replace sldu=48 if county=="Decatur" & sldl==95
replace sldu=12 if county=="Delaware" & sldl==24
replace sldu=16 if county=="Delaware" & sldl==32
replace sldu=44 if county=="Des Moines" & sldl==87
replace sldu=44 if county=="Des Moines" & sldl==88
replace sldu=3 if county=="Dickinson" & sldl==6
replace sldu=13 if county=="Dubuque" & sldl==25
replace sldu=14 if county=="Dubuque" & sldl==27
replace sldu=14 if county=="Dubuque" & sldl==28
replace sldu=16 if county=="Dubuque" & sldl==31
replace sldu=16 if county=="Dubuque" & sldl==32
replace sldu=4 if county=="Emmet" & sldl==7
replace sldu=9 if county=="Fayette" & sldl==18
replace sldu=12 if county=="Fayette" & sldl==23
replace sldu=12 if county=="Fayette" & sldl==24
replace sldu=7 if county=="Floyd" & sldl==14
replace sldu=5 if county=="Franklin" & sldl==9
replace sldu=6 if county=="Franklin" & sldl==12
replace sldu=22 if county=="Franklin" & sldl==44
replace sldu=49 if county=="Fremont" & sldl==97
replace sldu=25 if county=="Greene" & sldl==50
replace sldu=20 if county=="Grundy" & sldl==40
replace sldu=29 if county=="Guthrie" & sldl==58
replace sldu=5 if county=="Hamilton" & sldl==9
replace sldu=5 if county=="Hamilton" & sldl==10
replace sldu=6 if county=="Hancock" & sldl==11
replace sldu=6 if county=="Hancock" & sldl==12
replace sldu=22 if county=="Hardin" & sldl==44
replace sldu=28 if county=="Harrison" & sldl==56
replace sldu=46 if county=="Henry" & sldl==91
replace sldu=7 if county=="Howard" & sldl==14
replace sldu=8 if county=="Howard" & sldl==15
replace sldu=4 if county=="Humboldt" & sldl==8
replace sldu=28 if county=="Ida" & sldl==55
replace sldu=20 if county=="Iowa" & sldl==39
replace sldu=38 if county=="Iowa" & sldl==76
replace sldu=13 if county=="Jackson" & sldl==25
replace sldu=21 if county=="Jasper" & sldl==41
replace sldu=21 if county=="Jasper" & sldl==42
replace sldu=36 if county=="Jasper" & sldl==71
replace sldu=45 if county=="Jefferson" & sldl==89
replace sldu=45 if county=="Jefferson" & sldl==90
replace sldu=15 if county=="Johnson" & sldl==29
replace sldu=15 if county=="Johnson" & sldl==30
replace sldu=39 if county=="Johnson" & sldl==77
replace sldu=39 if county=="Johnson" & sldl==78
replace sldu=40 if county=="Johnson" & sldl==79
replace sldu=45 if county=="Johnson" & sldl==89
replace sldu=16 if county=="Jones" & sldl==31
replace sldu=38 if county=="Keokuk" & sldl==76
replace sldu=4 if county=="Kossuth" & sldl==7
replace sldu=4 if county=="Kossuth" & sldl==8
replace sldu=46 if county=="Lee" & sldl==91
replace sldu=46 if county=="Lee" & sldl==92
replace sldu=15 if county=="Linn" & sldl==29
replace sldu=17 if county=="Linn" & sldl==33
replace sldu=17 if county=="Linn" & sldl==34
replace sldu=18 if county=="Linn" & sldl==35
replace sldu=18 if county=="Linn" & sldl==36
replace sldu=19 if county=="Linn" & sldl==37
replace sldu=19 if county=="Linn" & sldl==38
replace sldu=44 if county=="Louisa" & sldl==87
replace sldu=36 if county=="Lucas" & sldl==72
replace sldu=2 if county=="Lyon" & sldl==4
replace sldu=37 if county=="Madison" & sldl==73
replace sldu=36 if county=="Mahaska" & sldl==72
replace sldu=38 if county=="Mahaska" & sldl==75
replace sldu=36 if county=="Marion" & sldl==71
replace sldu=36 if county=="Marion" & sldl==72
replace sldu=22 if county=="Marshall" & sldl==43
replace sldu=22 if county=="Marshall" & sldl==44
replace sldu=49 if county=="Mills" & sldl==97
replace sldu=49 if county=="Mills" & sldl==98
replace sldu=7 if county=="Mitchell" & sldl==14
replace sldu=28 if county=="Monona" & sldl==55
replace sldu=28 if county=="Monona" & sldl==56
replace sldu=36 if county=="Monroe" & sldl==72
replace sldu=48 if county=="Montgomery" & sldl==96
replace sldu=40 if county=="Muscatine" & sldl==79
replace sldu=40 if county=="Muscatine" & sldl==80
replace sldu=44 if county=="Muscatine" & sldl==87
replace sldu=3 if county=="O'Brien" & sldl==5
replace sldu=3 if county=="Osceola" & sldl==5
replace sldu=49 if county=="Page" & sldl==97
replace sldu=4 if county=="Palo Alto" & sldl==7
replace sldu=2 if county=="Plymouth" & sldl==3
replace sldu=27 if county=="Plymouth" & sldl==53
replace sldu=4 if county=="Pocahontas" & sldl==8
replace sldu=21 if county=="Polk" & sldl==42
replace sldu=30 if county=="Polk" & sldl==59
replace sldu=30 if county=="Polk" & sldl==60
replace sldu=31 if county=="Polk" & sldl==61
replace sldu=31 if county=="Polk" & sldl==62
replace sldu=32 if county=="Polk" & sldl==63
replace sldu=32 if county=="Polk" & sldl==64
replace sldu=33 if county=="Polk" & sldl==65
replace sldu=33 if county=="Polk" & sldl==66
replace sldu=34 if county=="Polk" & sldl==67
replace sldu=34 if county=="Polk" & sldl==68
replace sldu=35 if county=="Polk" & sldl==69
replace sldu=35 if county=="Polk" & sldl==70
replace sldu=28 if county=="Pottawattamie" & sldl==56
replace sldu=29 if county=="Pottawattamie" & sldl==57
replace sldu=49 if county=="Pottawattamie" & sldl==98
replace sldu=50 if county=="Pottawattamie" & sldl==99
replace sldu=50 if county=="Pottawattamie" & sldl==100
replace sldu=38 if county=="Poweshiek" & sldl==75
replace sldu=38 if county=="Poweshiek" & sldl==76
replace sldu=48 if county=="Ringgold" & sldl==96
replace sldu=26 if county=="Sac" & sldl==51
replace sldu=26 if county=="Sac" & sldl==52
replace sldu=41 if county=="Scott" & sldl==81
replace sldu=41 if county=="Scott" & sldl==82
replace sldu=42 if county=="Scott" & sldl==83
replace sldu=42 if county=="Scott" & sldl==84
replace sldu=43 if county=="Scott" & sldl==85
replace sldu=43 if county=="Scott" & sldl==86
replace sldu=29 if county=="Shelby" & sldl==57
replace sldu=2 if county=="Sioux" & sldl==3
replace sldu=2 if county=="Sioux" & sldl==4
replace sldu=3 if county=="Sioux" & sldl==5
replace sldu=5 if county=="Story" & sldl==10
replace sldu=23 if county=="Story" & sldl==45
replace sldu=23 if county=="Story" & sldl==46
replace sldu=20 if county=="Tama" & sldl==40
replace sldu=38 if county=="Tama" & sldl==76
replace sldu=48 if county=="Taylor" & sldl==96
replace sldu=48 if county=="Union" & sldl==95
replace sldu=48 if county=="Union" & sldl==96
replace sldu=45 if county=="Van Buren" & sldl==90
replace sldu=45 if county=="Wapello" & sldl==90
replace sldu=47 if county=="Wapello" & sldl==93
replace sldu=37 if county=="Warren" & sldl==73
replace sldu=37 if county=="Warren" & sldl==74
replace sldu=45 if county=="Washington" & sldl==89
replace sldu=47 if county=="Wayne" & sldl==94
replace sldu=4 if county=="Webster" & sldl==8
replace sldu=5 if county=="Webster" & sldl==9
replace sldu=25 if county=="Webster" & sldl==49
replace sldu=25 if county=="Webster" & sldl==50
replace sldu=6 if county=="Winnebago" & sldl==11
replace sldu=8 if county=="Winneshiek" & sldl==15
replace sldu=8 if county=="Winneshiek" & sldl==16
replace sldu=1 if county=="Woodbury" & sldl==1
replace sldu=1 if county=="Woodbury" & sldl==2
replace sldu=27 if county=="Woodbury" & sldl==53
replace sldu=27 if county=="Woodbury" & sldl==54
replace sldu=28 if county=="Woodbury" & sldl==55
replace sldu=6 if county=="Worth" & sldl==11
replace sldu=5 if county=="Wright" & sldl==9

gen fcounty=.
replace fcounty=1 if county=="Adair"
replace fcounty=3 if county=="Adams"
replace fcounty=5 if county=="Allamakee"
replace fcounty=7 if county=="Appanoose"
replace fcounty=9 if county=="Audubon"
replace fcounty=11 if county=="Benton"
replace fcounty=13 if county=="Black Hawk"
replace fcounty=15 if county=="Boone"
replace fcounty=17 if county=="Bremer"
replace fcounty=19 if county=="Buchanan"
replace fcounty=21 if county=="Buena Vista"
replace fcounty=23 if county=="Butler"
replace fcounty=25 if county=="Calhoun"
replace fcounty=27 if county=="Carroll"
replace fcounty=29 if county=="Cass"
replace fcounty=31 if county=="Cedar"
replace fcounty=33 if county=="Cerro Gordo"
replace fcounty=35 if county=="Cherokee"
replace fcounty=37 if county=="Chickasaw"
replace fcounty=39 if county=="Clarke"
replace fcounty=41 if county=="Clay"
replace fcounty=43 if county=="Clayton"
replace fcounty=45 if county=="Clinton"
replace fcounty=47 if county=="Crawford"
replace fcounty=49 if county=="Dallas"
replace fcounty=51 if county=="Davis"
replace fcounty=53 if county=="Decatur"
replace fcounty=55 if county=="Delaware"
replace fcounty=57 if county=="Des Moines"
replace fcounty=59 if county=="Dickinson"
replace fcounty=61 if county=="Dubuque"
replace fcounty=63 if county=="Emmet"
replace fcounty=65 if county=="Fayette"
replace fcounty=67 if county=="Floyd"
replace fcounty=69 if county=="Franklin"
replace fcounty=71 if county=="Fremont"
replace fcounty=73 if county=="Greene"
replace fcounty=75 if county=="Grundy"
replace fcounty=77 if county=="Guthrie"
replace fcounty=79 if county=="Hamilton"
replace fcounty=81 if county=="Hancock"
replace fcounty=83 if county=="Hardin"
replace fcounty=85 if county=="Harrison"
replace fcounty=87 if county=="Henry"
replace fcounty=89 if county=="Howard"
replace fcounty=91 if county=="Humboldt"
replace fcounty=93 if county=="Ida"
replace fcounty=95 if county=="Iowa"
replace fcounty=97 if county=="Jackson"
replace fcounty=99 if county=="Jasper"
replace fcounty=101 if county=="Jefferson"
replace fcounty=103 if county=="Johnson"
replace fcounty=105 if county=="Jones"
replace fcounty=107 if county=="Keokuk"
replace fcounty=109 if county=="Kossuth"
replace fcounty=111 if county=="Lee"
replace fcounty=113 if county=="Linn"
replace fcounty=115 if county=="Louisa"
replace fcounty=117 if county=="Lucas"
replace fcounty=119 if county=="Lyon"
replace fcounty=121 if county=="Madison"
replace fcounty=123 if county=="Mahaska"
replace fcounty=125 if county=="Marion"
replace fcounty=127 if county=="Marshall"
replace fcounty=129 if county=="Mills"
replace fcounty=131 if county=="Mitchell"
replace fcounty=133 if county=="Monona"
replace fcounty=135 if county=="Monroe"
replace fcounty=137 if county=="Montgomery"
replace fcounty=139 if county=="Muscatine"
replace fcounty=141 if county=="O'Brien"
replace fcounty=143 if county=="Osceola"
replace fcounty=145 if county=="Page"
replace fcounty=147 if county=="Palo Alto"
replace fcounty=149 if county=="Plymouth"
replace fcounty=151 if county=="Pocahontas"
replace fcounty=153 if county=="Polk"
replace fcounty=155 if county=="Pottawattamie"
replace fcounty=157 if county=="Poweshiek"
replace fcounty=159 if county=="Ringgold"
replace fcounty=161 if county=="Sac"
replace fcounty=163 if county=="Scott"
replace fcounty=165 if county=="Shelby"
replace fcounty=167 if county=="Sioux"
replace fcounty=169 if county=="Story"
replace fcounty=171 if county=="Tama"
replace fcounty=173 if county=="Taylor"
replace fcounty=175 if county=="Union"
replace fcounty=177 if county=="Van Buren"
replace fcounty=179 if county=="Wapello"
replace fcounty=181 if county=="Warren"
replace fcounty=183 if county=="Washington"
replace fcounty=185 if county=="Wayne"
replace fcounty=187 if county=="Webster"
replace fcounty=189 if county=="Winnebago"
replace fcounty=191 if county=="Winneshiek"
replace fcounty=193 if county=="Woodbury"
replace fcounty=195 if county=="Worth"
replace fcounty=197 if county=="Wright"
